//获取应用实例
var app = getApp();
Page({
    data: {
        platform:"iPhone"
    },
    onLoad: function () {
        var data = app.getStorageSync(app.globalData.cacheOrderResKey);
        this.setData({
            "serviceFeeDesc":data.serviceFeeDesc,
            "serviceFee":data.serviceFee,
            "cardNbr":data.cardNbr,
            "cardName":data.cardName,
            "certPlaceName":data.certPlaceName,
            "address.street":data['address.street'],
            "address.provinceId":data['address.provinceId'],
            "address.cityId":data['address.cityId'],
            "address.countyId":data['address.countyId'],
            "address.provinceName":data['address.provinceName'],
            "address.cityName":data['address.cityName'],
            "address.countyName":data['address.countyName'],
            "address.cellNum":data['address.cellNum'],
            "address.contactName":data['address.contactName'],
            "address.fullAddr":data['address.fullAddr'],
            "needInvoice":data.needInvoice
        });
        if(app.isAndroid()){
            this.setData({platform:"android"});
        }
    },
    formSubmit:function (e) {
        var param = app.getStorageSync(app.globalData.cacheOrderResKey);

        param['platform'] = this.data.platform;
        param['formId'] = e.detail.formId;
        param['payType'] = 0;
        param['accountId'] = app.globalData.openId;
        var opt = {
            url: app.globalData.host+"/wx/de/pay.ajax",
            data: param,
            sucFn:function (result) {
                param['orderId'] = result.body.orderIds[0].id;
                app.setStorageSync(app.globalData.cacheOrderResKey, param);
                var obj = app.getStorageSync(app.globalData.cachePageKey);//下单成功清除身份证号和名称
                obj.cardNbr = null;
                obj.cardName = null;
                obj.num = obj.num + 1;
                app.setStorageSync(app.globalData.cachePageKey, obj);
                app.redirectTo({url:'../paysuccess/paysuccess'});
            }
        };
        app.ajax(opt);
    }
});
